package com.aspose.cells;

import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;

class zcfo {
   static int a = 0;
   static int b = 0;
   static int c = 0;
   static String d = "";
   static HashMap e = new HashMap();
   static HashMap f = new HashMap();
   static ArrayList g = new ArrayList();
   static ArrayList h = new ArrayList();

   static void a(XmlMap var0, ListObject var1, String var2, int var3, String var4) {
      ListColumn var5 = new ListColumn(var1.getListColumns(), var4, var3);
      var5.c(var4);
      var5.a = new XmlColumnProperty();
      var5.a.a = var0.c;
      var5.a.c = "string";
      if (var4.length() > 0) {
         var5.a.b = var2 + "/" + "@" + var4;
      } else {
         var5.a(var2.substring(var2.lastIndexOf("/") + 1));
         var5.a.b = var2;
      }

      var1.getListColumns().a(var5);
   }

   static void a(String var0, Object var1, int var2, String var3, zams var4) {
      var4.c = var0;
      com.aspose.cells.b.a.a.ze.a(var4.d, var1);
      var4.e = var2;
      var4.a = var3;
      int var5 = var3.lastIndexOf(47);
      var4.b = var3.substring(0, 0 + var5);
      if (var2 > a) {
         a = var2;
      }

   }

   static boolean a(zcfh var0) {
      if (var0.getCount() == 1) {
         zcfg var1 = var0.a(0);
         if (var1.i().startsWith("xmlns")) {
            return true;
         }
      }

      return false;
   }

   static void a(XmlMap var0, ListObject var1, zcfl var2, int var3, String var4, Worksheet var5, int var6, int var7, int var8) {
      boolean var9 = false;
      ArrayList var10 = new ArrayList();
      boolean var11 = false;
      var4 = var4 + "/" + var2.g;
      zcfh var12 = var2.e();
      zcfs var13 = var2.j();
      int var21;
      if (var12.getCount() > 0 && !a(var12)) {
         var6 = 0;

         for(var21 = 0; var21 < var12.getCount(); ++var21) {
            zcfg var22 = var12.a(var21);
            int var20 = var1.getListColumns().getCount();
            if (!e.containsKey(var4)) {
               zams var24 = new zams();
               a(var22.i(), var22.h, var8, var4, var24);
               com.aspose.cells.b.a.a.ze.a(var10, (Object)var24);
            } else {
               ArrayList var16 = (ArrayList)e.get(var4);

               zams var18;
               for(int var17 = 0; var17 < var16.size(); ++var17) {
                  var18 = (zams)var16.get(var17);
                  if (com.aspose.cells.b.a.zv.b(var18.c, var22.i())) {
                     com.aspose.cells.b.a.a.ze.a(var18.d, (Object)var22.h);
                     var11 = true;
                     break;
                  }
               }

               if (!var11) {
                  String var27 = var22.h;
                  if (var27.length() > 0 && var27.indexOf("\n") == -1) {
                     var18 = new zams();
                     a(var22.i(), var27, var8, var4, var18);
                     com.aspose.cells.b.a.a.ze.a(var16, (Object)var18);
                  }
               }
            }
         }

         if (var10.size() > 0) {
            e.put(var4, var10);
            f.put(var4, c);
            ++c;
         }
      } else if (var13 != null && var13.a() == 1) {
         zcfq var14 = var13.a(0);
         if (var14 instanceof zcfv) {
            zams var15 = new zams();
            a(var2.i(), var2.a(), var8, var4, var15);
            com.aspose.cells.b.a.a.ze.a(var10, (Object)var15);
         }
      }

      if (var13.a() > 0) {
         for(var21 = 0; var21 < var13.a(); ++var21) {
            zcfq var23 = var13.a(var21);
            if (var23 instanceof zcfl) {
               if (var23 instanceof zcfl) {
                  zcfl var26 = (zcfl)var23;
                  a(var0, var1, var26, var3, var4, var5, var6, var7, var8 + 1);
               }
            } else if (!e.containsKey(var4)) {
               if (var10.size() > 0) {
                  e.put(var4, var10);
                  f.put(var4, c);
                  ++c;
               }
            } else if (var23 instanceof zcfv) {
               String var25 = ((zcfv)var23).b.i();
               ArrayList var28 = (ArrayList)e.get(var4);

               zams var19;
               for(int var29 = 0; var29 < var28.size(); ++var29) {
                  var19 = (zams)var28.get(var29);
                  if (com.aspose.cells.b.a.zv.b(var19.c, var25)) {
                     com.aspose.cells.b.a.a.ze.a(var19.d, (Object)((zcfv)var23).h);
                     var11 = true;
                     break;
                  }
               }

               if (!var11) {
                  String var30 = ((zcfv)var23).h;
                  if (var30.length() > 0 && var30.indexOf("\n") == -1) {
                     var19 = new zams();
                     a(var25, var30, var8, var4, var19);
                     com.aspose.cells.b.a.a.ze.a(var28, (Object)var19);
                  }
               }
            }
         }
      }

   }

   private static void a(HashMap var0) {
      ArrayList var1 = new ArrayList(e.keySet());
      Collections.sort(var1);

      for(int var2 = 0; var2 < var1.size(); ++var2) {
         String var3 = (String)var1.get(var2);
         ArrayList var4 = (ArrayList)e.get(var3);
         zams var5 = (zams)var4.get(0);
         int var6 = var5.d.size();
         if (var6 > 1) {
            String var7 = var5.b;

            for(int var8 = 0; var8 < var1.size(); ++var8) {
               String var9 = (String)var1.get(var8);
               String var10 = var9.substring(0, 0 + var9.lastIndexOf(47));
               if (var7.indexOf(var9) != -1 || com.aspose.cells.b.a.zv.b(var10, var7)) {
                  ArrayList var11 = (ArrayList)e.get(var9);

                  for(int var12 = 0; var12 < var11.size(); ++var12) {
                     zams var13 = (zams)var11.get(var12);
                     int var14 = var13.d.size();
                     if (var14 == 1) {
                        var13.g += var6;
                     }
                  }
               }
            }
         }
      }

   }

   private static int b(HashMap var0) {
      int var1 = 0;
      int var2 = 0;
      ArrayList var3 = new ArrayList(e.keySet());
      Collections.sort(var3);

      for(int var4 = 0; var4 < var3.size(); ++var4) {
         String var5 = (String)var3.get(var4);
         ArrayList var6 = (ArrayList)e.get(var5);

         for(int var7 = 0; var7 < var6.size(); ++var7) {
            zams var8 = (zams)var6.get(var7);
            int var9 = var8.d.size();
            if (a == 2) {
               if (var8.e == a) {
                  var2 += var9;
               }
            } else if (var8.e < a) {
               if (!com.aspose.cells.b.a.zv.b(var8.b, d) && var8.b.indexOf(d) == -1) {
                  var1 += var9;
                  d = var8.b;
               } else if (var1 < var9 && var9 > 1) {
                  var1 = var9;
                  d = var8.b;
               }
            } else if (var2 < var9) {
               var2 = var9;
            }
         }
      }

      return var2 + var1;
   }

   private static String a(ListObject var0) {
      CellArea var1 = new CellArea();
      var1.StartRow = var0.getStartRow();
      var1.StartColumn = var0.getStartColumn();
      var1.EndRow = var0.getEndRow();
      if (var0.getEndRow() - var0.getStartRow() == 0) {
         ++var1.EndRow;
      }

      var1.EndColumn = var0.getEndColumn();
      return zase.a(var1);
   }

   static void a(XmlMap var0, String var1, Worksheet var2, ListObject var3, int var4, int var5) throws Exception {
      try {
         byte var6 = 0;
         boolean var7 = false;
         boolean var8 = false;
         String var9 = "";
         String var10 = "";
         int var11 = 0;
         int var12 = var4 + 1;
         zcfk var13 = zass.a((String)var1, (zcft)null, false);
         zcfl var14 = var13.d_();
         if (var14 == null) {
            return;
         }

         var0.g = var14.g;
         var0.d = var14.g + "_map";
         int var15 = 0;
         int var29 = var4 + 1;
         int var30 = var5;
         a(var0, var3, var14, var15, "", var2, var29, var5, var6);
         int var16 = b(e);
         a(e);
         ArrayList var17 = new ArrayList(f.values());
         ArrayList var18 = new ArrayList();
         Collections.sort(var17);
         Iterator var19 = var17.iterator();

         while(var19.hasNext()) {
            int var20 = (Integer)var19.next();
            com.aspose.cells.b.a.a.zc var21 = com.aspose.cells.b.a.a.zf.a(f);

            while(var21.c()) {
               int var22 = (Integer)var21.b();
               if (var20 == var22) {
                  com.aspose.cells.b.a.a.ze.a(var18, var21.a());
               }
            }
         }

         int var31;
         for(var31 = 0; var31 < var18.size(); ++var31) {
            String var32 = (String)var18.get(var31);
            String var33 = var32.substring(0, 0 + var32.lastIndexOf(47));
            if (var31 > 0) {
               var9 = (String)var18.get(var31 - 1);
               var10 = var9.substring(0, 0 + var9.lastIndexOf(47));
            }

            ArrayList var34 = (ArrayList)e.get(var32);
            if (!com.aspose.cells.b.a.zv.b(var10, ((zams)var34.get(0)).b) && ((zams)var34.get(0)).b.indexOf(var10) == -1 && ((zams)var34.get(0)).d.size() > 1) {
               var12 += var11;
            } else {
               var12 = var4 + 1;
            }

            var29 = var12;

            for(int var23 = 0; var23 < var34.size(); ++var23) {
               zams var24 = (zams)var34.get(var23);
               ListColumn var25 = var3.getListColumns().get(var24.c);
               if (var25 == null) {
                  a(var0, var3, var32, var15, var24.c);
               } else {
                  ++var25.b;
                  a(var0, var3, var32, var15, var24.c + (var25.b + 1));
               }

               ArrayList var26 = var24.d;
               int var27;
               if (var26.size() > 1) {
                  for(var27 = 0; var27 < var26.size(); ++var27) {
                     var2.getCells().get(var29, var30).putValue(var26.get(var27));
                     ++var29;
                  }
               } else if (var24.g > 0) {
                  for(var27 = 0; var27 < var24.g; ++var27) {
                     var2.getCells().get(var29, var30).putValue(var26.get(0));
                     ++var29;
                  }
               } else {
                  for(var27 = 0; var27 < var16; ++var27) {
                     var2.getCells().get(var29, var30).putValue(var26.get(0));
                     ++var29;
                  }
               }

               ++var15;
               ++var30;
               var29 = var12;
               if (var24.g != 0) {
                  var11 = var24.g;
               } else if (var24.d.size() > 0) {
                  var11 = var24.d.size();
               }
            }
         }

         for(var31 = 0; var31 < var3.getListColumns().getCount(); ++var31) {
            var2.getCells().get(0, var31).putValue(var3.getListColumns().get(var31).getName());
         }

         var2.autoFitColumns();
         var3.a(var4);
         var3.b(var5);
         var3.c(var16);
         var3.d(var3.getListColumns().getCount() - 1);
         ++var2.c().j;
         var3.j(1);
         var3.getAutoFilter().setRange(a(var3));
         var3.setTableStyleType(23);
         var3.k(var2.getListObjects().getCount());
         var3.c = 2;
      } catch (Exception var28) {
         ;
      }

   }
}
